package com.qf.service.impl;

import com.qf.dao.OwnerMapper;
import com.qf.pojo.Owner;
import com.qf.pojo.OwnerExample;
import com.qf.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OwnerServiceImpl implements OwnerService {
    @Autowired
    private OwnerMapper ownerMapper;

    @Override
    public List<Owner> findAll() {
        return ownerMapper.selectByExample(null);
    }

    @Override
    public Owner findById(Integer id) {
        return ownerMapper.selectByPrimaryKey(id);
    }

    @Override
    public void removeOne(Integer id) {
        ownerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void removeList(List<Integer> ids) {
        OwnerExample ownerExample = new OwnerExample();
        OwnerExample.Criteria criteria = ownerExample.createCriteria();
        criteria.andIdIn(ids);
        ownerMapper.deleteByExample(ownerExample);
    }

    @Override
    public void addOwner(Owner owner) {
        ownerMapper.insert(owner);
    }

    @Override
    public void updateOwner(Owner owner) {
        ownerMapper.updateByPrimaryKey(owner);
    }
}
